var obj;
var CurrentUser=getUserID();
if(window.XMLHttpRequest){obj = new XMLHttpRequest();}
		else{obj = new ActiveXObject("Microsoft.XMLHTTP");}
var CurrentUser=getUserID();
	function GetDataProcess(type,urlPath){
	    switch (type){
		case 'sujectList':
			urlPath+="/"+CurrentUser;	
			obj.onreadystatechange = processSubjectListResult;
			break;
		case 'questionList':
			var TopicID=gup("TopicID");			
			var topicName= gup("Topic");
			urlPath+="/"+TopicID;			
			document.getElementById("btn_addnewQuestion").setAttribute("href","Question.html?TopicID="+TopicID+"&Topic="+topicName);
			obj.onreadystatechange = processQuestionListResult;
			break;
		case 'answerList':
			var QuestionID= gup("QuestionID");	
			
			urlPath+="/"+QuestionID;	
			obj.onreadystatechange = LoadQuestionItems;
			break;
		case 'questionImage':
			var QuestionID=gup("QuestionID");	
			var TopicID=gup("TopicID");			
			var topicName= gup("Topic");
			var AnswerID=gup("AnswerID");
			if (AnswerID |= "")
				{
				urlPath='./rest/questionImage/getByAnswer/'+AnswerID;
				document.getElementById("btn_addnewQuestion").setAttribute("href","QuestionImageDetail.html?AnswerID="+AnswerID+"&QuestionID="+QuestionID+"&TopicID="+TopicID+"&Topic="+topicName);
				}
			else{
				urlPath+="/"+QuestionID;
				document.getElementById("btn_addnewQuestion").setAttribute("href","QuestionImageDetail.html?QuestionID="+QuestionID+"&TopicID="+TopicID+"&Topic="+topicName);
			}
					
			
			obj.onreadystatechange = processQuestionImgListResult;
			break;
		case 'GetImageList':			
			urlPath+="/abc";			
			//document.getElementById("btn_addnewQuestion").setAttribute("href","QuestionImageDetail.html?QuestionID="+QuestionID+"&TopicID="+TopicID+"&Topic="+topicName);
			obj.onreadystatechange = processGetAllImages;
			break;
			//processGetAllImages
		case 'subject':
			var SubjectID=gup("SubjectID");			
			if (SubjectID!="" ){
				urlPath+="/"+SubjectID;
				obj.onreadystatechange = loadEditSubject;}
			else{
				ClearSubjectsObject();
				document.getElementById("btnSubSave").setAttribute("onClick","javascript:AddSubjectProcessing();");
			}
			break;
		case 'question':
			var topicName= gup("Topic");
			var QuestionID=gup("QuestionID");	
			document.getElementById("txtTopic").value=String(topicName).replace("%20"," ");
			if (QuestionID!="" ){
				urlPath+="/"+QuestionID;
				document.getElementById("txtQuestionID").value=QuestionID;
				obj.onreadystatechange = loadEditQuestion;
				document.getElementById("btnQueSave").setAttribute("onClick","javascript:UpdateQuestionProcessing();");
				}
			else{
				document.getElementById("txtQuestionID").value="<Auto>";
				document.getElementById("btnQueSave").setAttribute("onClick","javascript:AddQuestionProcessing();");
				}
			document.getElementById("txtQuestionID").disabled=true;
			document.getElementById("txtTopic").disabled=true;
			break;
		case 'topicload':
				loadSubjectDDL();
				loadTopicDDL();
				var TopicID="";
				try{
					TopicID=gup("TopicID");	
					//alert(TopicID);
				}
				catch(err){					
					alert(err);
				};
			if (TopicID != ""){
				urlPath += "/"+TopicID;
				obj.onreadystatechange = loadEditTopic;
				//return;
				}
			else{	
				document.getElementById("btnSubSave").setAttribute("onClick","javascript:AddTopicProcessing();");
				return;
					}
			break;
		case 'topicList':
			var SubjectID=gup("SubjectID");		
				urlPath+="/"+SubjectID+"/";
				obj.onreadystatechange = processTopicListResult;
				//alert(urlPath);
			break;
		default:
			//IFrame.src="Welcome.html";
			break;
		}
	    var url = urlPath;
	    obj.open("GET", url, true);
	    obj.send(null);
	}	
	function processSubjectListResult(){
		if (obj.readyState == 4) {
			//	alert("test2");
		        // 200 means "OK"
		        if (obj.status == 200) {
		        	
	        	var objReturn =eval ("(" + obj.responseText + ")");	
  	        	var rows=" ";
	        	for(var i=0; i< objReturn.SUBJECT.length; i++){
	        		rows += "<TR>";
	        		rows += "<TD>" + objReturn.SUBJECT[i].subjectID + "</TD>";
	        		rows += "<TD>" + objReturn.SUBJECT[i].subjectName + "</TD>";
	        		rows += "<TD>" + objReturn.SUBJECT[i].subjectShortName + "</TD>";
	        		rows += "<TD>" + objReturn.SUBJECT[i].subjectCredits + "</TD>";
	        		rows += "<TD><a href='TopicList.html?SubjectID="+objReturn.SUBJECT[i].subjectID+"'><img class='imgControl' src='./img/topic.png'></img></a></TD>" ;
	        		rows += "<TD><a href='Subject.html?SubjectID="+objReturn.SUBJECT[i].subjectID+"'><img class='imgControl' src='./img/edit.png'></img></a></TD>" ;
	        		rows += "<TD><a href=\"javascript:DeleteSubject('"+objReturn.SUBJECT[i].subjectID+"');\"><img class='imgControl' src='./img/delete.png'></img></a></TD>";
	        	}
	        	var table="<table>"+
							"<tr>"+
								"<th>Subject ID</th>"+
								"<th>Subject Name</th>"+
								"<th>Short Name</th>"+
								"<th>Credits</th>"+
								"<th>Manage Topic</th>"+
								"<th>Modify</th>"+
								"<th>Remove</th>"+
							"</tr>"+rows+
							"</table>";
	        	document.getElementById("divShow").innerHTML = table;
		        } else {
		        	document.getElementById("info").innerHTML = "There was a problem in the returned data";
		        }
		    }
		}
	function processQuestionListResult(){
		var TopicID=gup("TopicID");	
		var TopicName=gup("Topic");
		if (obj.readyState == 4) {
			//	alert("test2");
		        // 200 means "OK"
		        if (obj.status == 200) {
		        		
	        	var objReturn =eval ("(" + obj.responseText + ")");	
  	        	var rows=" ";  	        	
	        	for(var i=0; i< objReturn.QUESTION.length; i++){
	        		rows += "<TR>";
	        		rows += "<TD>" + objReturn.QUESTION[i].questID + "</TD>";
	        		rows += "<TD>" + TopicName + "</TD>";
	        		rows += "<TD>" + objReturn.QUESTION[i].lecturerID + "</TD>";
	        		rows += "<TD>" + objReturn.QUESTION[i].questDesc + "</TD>";
	        		rows += "<TD>" + objReturn.QUESTION[i].questType + "</TD>";
	        		rows += "<TD>" + objReturn.QUESTION[i].level + "</TD>";
	        		rows += "<TD><a href='QuestionImages.html?QuestionID="+objReturn.QUESTION[i].questID+	        		
			        		"&type="+objReturn.QUESTION[i].questType+
		    				"&TopicID="+TopicID+"&Topic=" +TopicName+
		    				"'><img class='imgControl' src='./img/imgFolder.png'></img></a></TD>" ;
	        		rows += "<TD><a href='QuestionItemEditpage.html?QuestionID="+objReturn.QUESTION[i].questID+	        		
	        				"&type="+objReturn.QUESTION[i].questType+
	        				"&TopicID="+TopicID+"&Topic=" +TopicName+
	        				"'><img class='imgControl' src='./img/tree.png'></img></a></TD>" ;
	        		rows += "<TD><a href='Question.html?QuestionID="+objReturn.QUESTION[i].questID+"" +
			        		"&type="+objReturn.QUESTION[i].questType+
			        		"&TopicID="+TopicID+"&Topic=" +TopicName+
			        		"'><img class='imgControl' src='./img/edit.png'></img></a></TD>" ;
	        		rows += "<TD><a href=\"javascript:DeleteQuestion('"+objReturn.QUESTION[i].questID+"');\"><img class='imgControl' src='./img/delete.png'></img></a></TD>";
	        	}
	        	var table="<table>"+
							"<tr>"+
								"<th>Question ID</th>"+
								"<th>Topic</th>"+
								"<th>Created by</th>"+
								"<th>Short Desc</th>"+
								"<th>Question Type</th>"+
								"<th>Level</th>"+
								"<th>Manage Figures</th>"+
								"<th>Question Items</th>"+
								"<th>Edit</th>"+
								"<th>Delete</th>"+

							"</tr>"+rows+
							"</table>";
	        	document.getElementById("divShow").innerHTML = table;
		        } else {
		        	document.getElementById("info").innerHTML = "There was a problem in the returned data";
		        }
		    }
		}
		
	function processQuestionImgListResult(){	
		if (obj.readyState == 4) {		
		        if (obj.status == 200) {
	        	var objReturn =eval ("(" + obj.responseText + ")");	
  	        	var rows=" ";  	   	        	
	        	for(var i=0; i< objReturn.QUESTION_IMG.length; i++){	        	
	        	rows += "<TR>";
	        		rows += "<TD>" + objReturn.QUESTION_IMG[i].questImgID + "</TD>";	        		
	        		rows += "<TD><img  class='imgThumb' src='./images/" + objReturn.QUESTION_IMG[i].questImgLink + "'></img></TD>";
	        		rows += "<TD><a href='QuestionImageDetail.html?ImgID="+objReturn.QUESTION_IMG[i].questImgID+"" +
	        				"&QuestionID="+objReturn.QUESTION_IMG[i].questID+""+
	        				"&AnswerID="+objReturn.QUESTION_IMG[i].answerID+""+
	        				"'><img class='imgControl' src='./img/edit.png'></img></a></TD>" ;
	        		rows += "<TD><a href=\"javascript:DeleteQuestionImg('"+objReturn.QUESTION_IMG[i].questImgID+"');\"><img class='imgControl' src='./img/delete.png'></img></a></TD>";
	        		rows += "</tr>";
	        	}
	        	var table="<table>"+
							"<tr>"+
								"<th>Image ID</th>"+
								"<th>Image</th>"+
								"<th>Edit</th>"+
								"<th>Delete</th>"+

							"</tr>"+rows+
							"</table>";
	        	  // alert(table);
	        	   document.getElementById("divShow").innerHTML = table;
		        } else {
		        	document.getElementById("info").innerHTML = "There was a problem in the returned data";
		        }
		   
		    }
		}


	function processGetAllImages(){
		if (obj.readyState == 4) {
		        if (obj.status == 200) {
		        //	alert(obj.responseText);
	        	var objReturn =eval ("(" + obj.responseText + ")");	
  	        	var rows=" ";  	 
  	        	var ImgID=gup("ImgID");
	        	for(var i=0; i< objReturn.QUESTION_IMG.length; i++){
	          		if (include([".JPG",".PNG",".GIF"],Right(objReturn.QUESTION_IMG[i].image,4).toUpperCase())==true)
	        			{rows += "<span class='spanThumb'>" ;
	          			if (ImgID |= "")
	          				rows +="<a href='javascript:UpdateQuestionImg(\""+objReturn.QUESTION_IMG[i].image+"\");'><img class='imgThumb' src='./images/"+objReturn.QUESTION_IMG[i].image+"'></img></a>";
	          			else{
	          				rows +="<a href='javascript:InsertQuestionImg(\""+objReturn.QUESTION_IMG[i].image+"\");'><img class='imgThumb' src='./images/"+objReturn.QUESTION_IMG[i].image+"'></img></a>";
	          			}	        			
	        			rows +="</span>";}
	        	}
	        	
	        	document.getElementById("divShowExisted").innerHTML = rows;
		        } else {
		        	document.getElementById("info").innerHTML = "There was a problem in the returned data";
		        }
		   
		    }
		}	
	function processTopicListResult(){
		//alert(obj.status);
		var SubjectID=gup("SubjectID");
		if (obj.readyState == 4) {
	        if (obj.status == 200) {
		        	var objReturn =eval ("(" + obj.responseText + ")");	
	              	var rows=" ";
	              //	alert(objReturn.TOPIC.length);
	              	for(var i=0; i< objReturn.TOPIC.length; i++){
	              		
	        		rows += "<TR>";
	        		rows += "<TD>" + objReturn.TOPIC[i].topicID + "</TD>";
	        		rows += "<TD>" + objReturn.TOPIC[i].topicName + "</TD>";
	        		rows += "<TD>" + objReturn.TOPIC[i].topTopicID + "</TD>";
	        		rows += "<TD>" + objReturn.TOPIC[i].topicNote + "</TD>";
	        		rows += "<TD><a href='QuestionList.html?TopicID="+objReturn.TOPIC[i].topicID+"&Topic="+objReturn.TOPIC[i].topicName+"'><img class='imgControl' src='./img/topic.png'></img></a></TD>" ;
	        		rows += "<TD><a href='Topic.html?TopicID="+objReturn.TOPIC[i].topicID+"&SubjectID="+SubjectID+"'><img class='imgControl' src='./img/edit.png'></img></a></TD>" ;
	        		rows += "<TD><a href=\"javascript:DeleteTopic('"+objReturn.TOPIC[i].topicID+"');\"><img class='imgControl' src='./img/delete.png'></img></a></TD>";
	        		rows += "</TR>";
	        	}
	        	//alert(rows);
	        	var table="<table>"+
	"<tr>"+
		"<th>Topic ID</th>"+
		"<th>Topic Name</th>"+
		"<th>Top Topic</th>"+
		"<th>Topic Note</th>"+
		"<th>Manage Questions</th>"+
		"<th>Modify</th>"+
		"<th>Remove</th>"+
	"</tr>"+rows+
	"</table>";
	        	//alert(table);
	        	document.getElementById("divShow").innerHTML = table;
	    	       		
	        } else {
	        	document.getElementById("info").innerHTML = "There was a problem in the returned data";
	        }
	    }
	}	
	function DeleteSubject(SubjectID){
		if (window.confirm("Are you sure to delete Subject have ID: "+SubjectID+" ?")){
		var urlPath = "./rest/subject/delete/"+SubjectID;
		
		obj.onreadystatechange = function(){		
			if (obj.readyState == 4) {
				//alert(urlPath);
			        if (obj.status == 200) {
			        	alert(obj.responseText);
			        	location.reload(); 
			        }
			        else{alert("Error: Pls try again!"+obj.responseText+" --- ");}	
			   }
			
		};		
		obj.open("GET",urlPath,true);
		obj.send(null);}
		else
			return;
	}
	function ClearSubjectsObject(){
		document.getElementById("txtSubjectID").disabled=false;
		document.getElementById("txtSubjectID").value="";
		document.getElementById("txtSubjectName").value ="";
		document.getElementById("txtSubjectShortName").value ="";
		document.getElementById("txtSubjectCredits").value ="";
	}
	
	function loadEditSubject(){
		if (obj.readyState == 4 && obj.status==200){
		        	var objReturn =eval ("(" + obj.responseText + ")");	
		        	document.getElementById("txtSubjectID").value =objReturn.SUBJECT.subjectID;
		        	document.getElementById("txtSubjectName").value =objReturn.SUBJECT.subjectName;
		        	document.getElementById("txtSubjectShortName").value =objReturn.SUBJECT.subjectShortName;
		        	document.getElementById("txtSubjectID").disabled=true;
		        	document.getElementById("txtSubjectCredits").value =objReturn.SUBJECT.subjectCredits;
		        	document.getElementById("btnSubSave").setAttribute("onClick","javascript:UpdateSubjectProcessing();");
		        }		      
	}
	function loadEditQuestion(){
		if (obj.readyState == 4 && obj.status==200){
		        	var objReturn =eval ("(" + obj.responseText + ")");	
		        	var Qtype=swapTypeKey(gup("type"));
		        	switch(Qtype){
		        	case "1":
		        		document.getElementById("rdtMultChoice").checked=true;
		        		break;
		        	case "2":
		        		document.getElementById("rdtFillBlank").checked=true;
			        	break;
		        	case "3":
		        		document.getElementById("rdtMatching").checked=true;
			        	break;
		        	case "4":
		        		document.getElementById("rdtFullText").checked=true;
			        	break;
		        	}
		        	document.getElementById("txtQuestionDesc").value =objReturn.QUESTION.questDesc;
		        	document.getElementById("txtQuestionLevel").value =objReturn.QUESTION.level;
//		           	document.getElementById("btnSubSave").setAttribute("onClick","javascript:UpdateSubjectProcessing();");
		        }		      
	}
	function loadSubjectDDL(){
		var obj1;
		if(window.XMLHttpRequest){obj1 = new XMLHttpRequest();}
		else{obj1 = new ActiveXObject("Microsoft.XMLHTTP");}
		var urlPath='./rest/subject/getAll';
		obj1.onreadystatechange =function(){
			if (obj1.readyState == 4) {						
	        if (obj1.status == 200) {
	        	
        	var objReturn1 =eval ("(" + obj1.responseText + ")");	
	        	var rows=" ";
        	for(var i=0; i< objReturn1.SUBJECT.length; i++){
        		rows += "<option value = '"+ objReturn1.SUBJECT[i].subjectID+"'> "+objReturn1.SUBJECT[i].subjectName+"</option>";
        		}
        	var table="<select id='ddl_SubjectList'>"+rows+
						"</select>";
        	document.getElementById("txtSubjectID").innerHTML = table;
	        } else {
	        	document.getElementById("info").innerHTML = "There was a problem in the returned data (Subject List)";
	        }
	    }};
		 
		 obj1.open("GET", urlPath, true);
		 obj1.send(null);
}
	function loadTopicDDL(){
		var obj2;
		if(window.XMLHttpRequest){obj2 = new XMLHttpRequest();}
				else{obj2 = new ActiveXObject("Microsoft.XMLHTTP");}
		var urlPath='./rest/topic/getAll';
		obj2.onreadystatechange =function(){
		if (obj2.readyState == 4) {
	        if (obj2.status == 200) {
		        	var objReturn2 =eval ("(" + obj2.responseText + ")");	
	              	var rows=" ";
	              //	alert( obj2.responseText );
	              	rows+="<option value='0'>Select</option>";
	              	for(var i=0; i< objReturn2.TOPIC.length; i++){
	              		rows += "<option value = '"+ objReturn2.TOPIC[i].topicID+"'> "+objReturn2.TOPIC[i].topicName+"</option>";
	            	}
	        	   var table="<select id='ddl_TopicList'>"+rows+"</select>";	        	
	        	document.getElementById("txtTopTopic").innerHTML = table;	    	       		
	        } else {
	        	document.getElementById("info").innerHTML = "There was a problem in the returned data (Topic List)";
	        }
	    }};
		
		 obj2.open("GET", urlPath, true);
		 obj2.send(null);
	}
	function loadEditTopic(){
		//alert(obj.status);
		if (obj.readyState == 4){
			if(obj.status == 200){
		    var ObjsubjectList=document.getElementById("ddl_SubjectList");
		    var ObjtopicList=document.getElementById("ddl_TopicList");
		    var objReturn =eval ("(" + obj.responseText + ")");	
        	var topicSubject=objReturn.TOPIC.topicSubject;
        	var ToptopicId=objReturn.TOPIC.topTopic ;
        	//alert(ToptopicId);
        	if (ToptopicId == null || ToptopicId=='null')
        		{ToptopicId="0";}
        	else
        		{ToptopicId=new String(objReturn.TOPIC.topTopic);}
        	  try{  
        		  var i;
        	for (i= 0; i < ObjsubjectList.options.length; i++ ) {
        		 if (String(ObjsubjectList.options[i].text) == topicSubject ) {
        			 ObjsubjectList.options[i].selected = true;
        			 
         	        }
        	    };
        	if (ToptopicId == 0 || ToptopicId == "0" || ToptopicId == null){
        		ObjtopicList.options[1].selected=true;
        		}
        	else{
        		for (i = 0; i < ObjtopicList.options.length; i++ ) 
        	 	{
        		 if (String(ObjtopicList.options[i].value) == ToptopicId ) {
     	        	ObjtopicList.options[i].selected = true;
     	        	}     	        
     	    	}        	
        	}
        	  }catch(err)
        	  {//alert(err);
        	  }
        	    document.getElementById("txtTopicName").value =objReturn.TOPIC.topicName;
            	document.getElementById("txtTopicNote").value =objReturn.TOPIC.topicNote;
            	document.getElementById("btnSubSave").setAttribute("onClick","javascript:UpdateTopicProcessing();");   
        }		      
		}
}

	function LoadQuestionItems()
	{
		//alert(obj.status);
		var type= gup("type");	
		var QID=gup('QuestionID');
		if (obj.readyState == 4) {
		   if (obj.status == 200) {
			    var objReturn =eval ("(" + obj.responseText + ")");	
			    topicId=gup("TopicID");
		    	topic=gup("Topic");
			    if (objReturn.ANSWER.length<1){
			    	window.location.href = 'QuestionItem.html?QuestionID='+QID+'&type='+type+'&TopicID='+topicId+'&Topic='+topic;	
			    	return;
			    }			    	    	
				    var rows=" "; 
				   	var QuestionType=swapTypeKey(type);
			    	var i=0;	
			    	var AnsID=1;			    	
			    	switch (QuestionType){
			    	case "1":
			    		for(i=0; i< objReturn.ANSWER.length; i++){
			    			AnsID=String(objReturn.ANSWER[i].answerID);			    			
			    			rows += "<span class='Span_Radio'>";
			        		rows += "&nbsp;&nbsp;<b style='min-width:69px; display:inline-block;'>Item ID: "+AnsID+" </b> ";
			        		if (objReturn.ANSWER[i].solution=="true"){
				        		rows += "&nbsp;&nbsp;<input type = 'radio' name = 'QType' id ='txtRadio"+AnsID+"' checked/>";	        			
			        		}else{
				        		rows += "&nbsp;&nbsp;<input type = 'radio' name = 'QType' id ='txtRadio"+AnsID+"' />";
			        		}
			        		rows += "&nbsp;&nbsp;<input class='txtQuestionItem' type='text' id='txtAnswer"+AnsID+"' value='"+objReturn.ANSWER[i].answerValue+"'/> ";
			        		rows += "&nbsp;&nbsp;<a title='Manage figures' href=\"javascript:UpdateQuestionItem_Muilt('"+AnsID+"')\"><img class='imgControl' src='./img/save.gif'></img></a>" ;
			        		rows += "&nbsp;&nbsp;<a href='QuestionImages.html?QuestionID="+QID+"&AnswerID="+AnsID+"&TopicID="+topicId+"&Topic="+topic+"'><img class='imgControl' src='./img/imgFolder.png'></img></a>" ;
			        		rows += "&nbsp;&nbsp;<a href=\"javascript:DeleteAnswerItem('"+AnsID+"');\"><img class='imgControl' src='./img/delete.png'></img></a>" +
			        				"<br clear='both'>" +
			        				"</span>";
			        	}		        	
			        	document.getElementById("divShow").innerHTML = rows;
				      		break;
			    		case "2":		
			    			for(i=0; i< objReturn.ANSWER.length; i++){
				    			AnsID=String(objReturn.ANSWER[i].answerID);			    			
				    			rows += "<span class='Span_Radio'>";
				        		rows += "<b style='min-width:69px; display:inline-block;'>Item ID: "+AnsID+" </b><br clear='both'/> ";
				        		rows += "<a class='aLittleLabel'>Paragraph :</a>"+
								"<TEXTAREA Name='txtFill"+AnsID+"' class='txtInput' id='txtFill"+AnsID+"'  ROWS=4 COLS=30>"+objReturn.ANSWER[i].answerDesc+"</TEXTAREA>"+
								"<br/><a class='aLittleLabel'>Blank :</a>"+
								"<input class='txtQuestionItem' type='text' id='txtAnswer"+AnsID+"' value='"+objReturn.ANSWER[i].answerValue+"'/>";				        	
				        		rows += "&nbsp;&nbsp;<a href=\"javascript:UpdateQuestionItem_FillBlank('"+AnsID+"')\"><img class='imgControl' src='./img/save.gif'></img></a>" ;
				        		rows += "&nbsp;&nbsp;<a href='QuestionImages.html?QuestionID="+QID+"&AnswerID="+AnsID+"&TopicID="+topicId+"&Topic="+topic+"'><img class='imgControl' src='./img/imgFolder.png'></img></a>" ;
				        		rows += "&nbsp;&nbsp;<a href=\"javascript:DeleteAnswerItem('"+AnsID+"');\"><img class='imgControl' src='./img/delete.png'></img></a>" +
				        				"<br/><br/><br clear='both'/>" +
				        				"</span>";
				        	}		        	
//				    		alert(rows);
				        	document.getElementById("divShow").innerHTML = rows;
			    			break;
			    		case "3":			  
			    			for(i=0; i< objReturn.ANSWER.length; i++){
				    			AnsID=String(objReturn.ANSWER[i].answerID);			    			
				    			rows += "<span class='Span_Radio'>";
				        		rows += "<b style='min-width:69px; display:inline-block;'>Item ID: "+AnsID+" </b><br clear='both'/> ";
				        		rows += "<a>Left :</a><input class='txtQuestionItem' type = 'text' name = 'QType' id ='txtMatching"+AnsID+"' value='"+objReturn.ANSWER[i].answerDesc+"' />"+
								"<a > - Right :</a>"+
								"<input class='txtQuestionItem' type='text' id='txtAnswer"+AnsID+"' value='"+objReturn.ANSWER[i].answerValue+"'/>";				        	
				        		rows += "&nbsp;&nbsp;<a href=\"javascript:UpdateQuestionItem_Matching('"+AnsID+"')\"><img class='imgControl' src='./img/save.gif'></img></a>" ;
				        		rows += "&nbsp;&nbsp;<a href='QuestionImages.html?QuestionID="+QID+"&AnswerID="+AnsID+"&TopicID="+topicId+"&Topic="+topic+"'><img class='imgControl' src='./img/imgFolder.png'></img></a>" ;
				        		rows += "&nbsp;&nbsp;<a href=\"javascript:DeleteAnswerItem('"+AnsID+"');\"><img class='imgControl' src='./img/delete.png'></img></a>" +
				        				"<br clear='both'/>" +
				        				"</span>";
				        	}		        	
//				    		alert(rows);
				        	document.getElementById("divShow").innerHTML = rows; 			
			    			break;
			    		default:	
				    			AnsID=String(objReturn.ANSWER[0].answerID);
					    		rows += "<center class='Span_Radio'>";
				        		rows += "<b style='min-width:69px; display:inline-block;'>Solution </b><br clear='both'/> ";
				        		rows += "<TEXTAREA Name='txtFill"+AnsID+"' class='txtInput' id='txtQuestionDesc'  ROWS=4 COLS=50>"+objReturn.ANSWER[0].answerDesc+"</TEXTAREA>";		        	
				        		rows += "<br/>&nbsp;&nbsp;<a href=\"javascript:UpdateQuestionItem_Fulltext('"+AnsID+"')\"><img class='imgControl' src='./img/save.gif'></img></a>" ;
				        		rows += "&nbsp;&nbsp;<a href='QuestionImages.html?QuestionID="+QID+"&AnswerID="+AnsID+"&TopicID="+topicId+"&Topic="+topic+"'><img class='imgControl' src='./img/imgFolder.png'></img></a>" ;
				        		rows += "&nbsp;&nbsp;<a href=\"javascript:DeleteAnswerItem('"+AnsID+"');\"><img class='imgControl' src='./img/delete.png'></img></a>" +
				        				"<br clear='both'/>" +
				        				"</center>";
				        		document.getElementById("divShow").innerHTML = rows; 
			    			break;
			    		}		
		   }
			} 
		
		
	}
	